package Test;

import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Arrays;
import java.util.concurrent.ConcurrentHashMap;

public class Test10 {
    
    public static void main(String[] args) throws UnknownHostException {
        InetAddress address = InetAddress.getLocalHost();//获取这个电脑的IP和主机名
        System.out.println(address);
        //获取这个主机的名字
        System.out.println(address.getHostName());
        //获取IP地址
        System.out.println(address.getHostAddress());
        InetAddress baidu = InetAddress.getByName("www.baidu.com");
        //获取百度的IP
        System.out.println(baidu.getHostAddress());
        //获取百度域名
        System.out.println(baidu.getHostName());
    }
}
